*********************************************************
*********************************************************  
*** GBR 2024 --- JPE Revision Package *******************
*** Code for stats analyses, Appendix D Study 6 *********
*** Public (anonymized) *********************************
*********************************************************

**************************
**** Clean Data  *********
**************************

clear all
set more off

cd ".../JPEReplicationPackageDataverse/"
qui: do GBR24CleaningStudy6.do



**************************
**** Data Preparation ****
**************************

clear all
set more off

** Load dataset from Study 6
use ".../JPEReplicationPackageDataverse/GBR24DataCleanStudy6.dta"

destring, replace



**************************
*** Appendix D text ****
**************************



* Total number of workers three schemes
count if low==1 | low_random==1 | high_random==1
* Summarize time spent in study and hourly pay
sum Durationinminutes
gen total_pay=0.04*l+0.05+0.95 if low==1 | low_random==1
replace total_pay=0.07*l+0.05+0.95 if high_random==1
sum total_pay
** Mean labor supply and mean standardized labor supply for low-wage workers
sum l if low_random==1
sum sd_l if low_random==1
sum l if low==1
sum sd_l if low==1
* Mean labor supply and mean standardized labor supply for low-wage workers from two schemes and for high-wage workers, and comparing them
sum l if low==1 | low_random==1
sum sd_l if low==1 | low_random==1
sum l if high_random==1
sum sd_l if high_random==1
ranksum sd_l, by(high_random)
tobit l high_random age40 age50 age60 num_approvals prolific_score woman student nat_uk white employed parttime unemployed notInPaidJob otheremployment p* if low==1 | low_random==1 | high_random==1, ll(0) ul(85) vce(robust)
test high_random
* Elasticity w.r.t. wage without inequality (50.77328 vs 46.31992 lines)
gen elasticity_wage_addstudy=((50.77328-46.31992)/46.31992)/ ((7-4)/4)
sum elasticity_wage_addstudy



**************************
*** Appendix D Tables ****
**************************



* Table D1: Piece-Rate Wage of the Worker for the Two Payment Schemes in Study 6
* Number of workers, first row:
count if low==1
* Number of workers, second row:
count if low_random==1 | high_random==1



** Table D2: Demographic Characteristics of Workers in Study 6
* Column 1: All schemes
sum age num_approvals woman student nat_uk white employed parttime  ///
unemployed notInPaidJob otheremployment
est clear
estpost tabstat age num_approvals woman student nat_uk white employed parttime ///
unemployed notInPaidJob otheremployment, c(stat) stat(mean sd) 
esttab, ///
 cells("mean(fmt(%13.2fc)) sd(fmt(%13.2fc))") nonumber ///
  nomtitle nonote noobs label collabels("Mean" "SD")
  esttab using  ".../JPEReplicationPackageDataverse/Tables/TableD2_demographics_allschemes.tex", replace ///
  main(mean %15.2f) aux(sd %15.2f) nostar nonumber unstack ///
   compress nonote noobs gap label booktabs f   ///
   collabels(none) ///
   eqlabels("All Schemes") /// 
   nomtitles 
* Columns 2 and 3: Low and Random schemes
sum age num_approvals woman student nat_uk white employed parttime  ///
unemployed notInPaidJob otheremployment if low==1
sum age num_approvals woman student nat_uk white employed parttime  ///
unemployed notInPaidJob otheremployment if low==0
est clear
estpost tabstat age num_approvals woman student nat_uk white employed parttime ///
unemployed notInPaidJob otheremployment, by(low) c(stat) stat(mean sd) nototal  
esttab, main(mean) aux(sd) nostar nonumber unstack ///
   nonote noobs label ///
   collabels(none) ///
   eqlabels("Low" "Random") /// 
   nomtitles
 esttab using ".../JPEReplicationPackageDataverse/Tables/TableD2_demographics_byscheme.tex", replace ///
  main(mean %15.2f) aux(sd %15.2f) nostar nonumber unstack ///
   compress nonote noobs gap label booktabs f   ///
   collabels(none) ///
   eqlabels("Low" "Random") /// 
   nomtitles  
* Column 4: t-test for each characteristic 
ttest age, by(low) unequal
ttest num_approvals, by(low) unequal
ttest woman, by(low) unequal
ttest student, by(low) unequal
ttest nat_uk, by(low) unequal
ttest white, by(low) unequal
ttest employed, by(low) unequal
ttest parttime, by(low) unequal
ttest unemployed, by(low) unequal
ttest notInPaidJob, by(low) unequal
ttest otheremployment, by(low) unequal



** Table D3: Labor Supply per Payment Scheme and p-values of Differences in Labor Supply between Schemes in Study 6
* Table D3 Upper part
sum l if low==1
tab l if low==1
sum l if low_random==1
tab l if low_random==1
sum l if high_random==1
tab l if high_random==1
sum sd_l if low==1
sum sd_l if low_random==1
sum sd_l if high_random==1
* Table D3 Lower part
ranksum sd_l if low==1 | low_random==1, by(low_random)
tobit l low_random age40 age50 age60 num_approvals prolific_score woman student nat_uk white employed parttime unemployed notInPaidJob otheremployment period* if low==1 | low_random==1, ll(0) ul(85) vce(robust)
test low_random



* Table D4: Tobit Regression of Labor Supply on Scheme in Study 6
tobit l low_random age40 age50 age60 num_approvals prolific_score woman student nat_uk white employed parttime unemployed notInPaidJob otheremployment period* if low==1 | low_random==1, ll(0) ul(85) vce(robust)
test low_random
